import java.util.Random;
import java.util.Scanner;

public class Test {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int tmp = 0;

        while(num2 != 0){
            tmp = num1 % num2;
            num1 = num2;
            num2 = tmp;
        }
        System.out.println(num1);

        /*int num = sc.nextInt();
        for(int i = 31;i >= 0;i--){
            if(i % 2 == 0){
                System.out.println("偶数位" + ((num >> i) & 1));
            }else{
                System.out.println("奇数位" + ((num >> i) & 1));
            }
        }*/
        //sc.close();
        /*
        int count = 5;
        long key = 21475;
        while(count != 0){
            System.out.println("请输入走进杨承娟心中的密码：" );
            long input = sc.nextLong();
            if(input == key){
                System.out.println("密码正确");
                break;
            }
            count--;
            System.out.println("密码错误（还有" + count + "次机会）");
        }
*/
      /*  int num = sc.nextInt();
        if(num < 0){
            num = -num;
        }
        while(num != 0){
            System.out.println(num % 10);
            num /= 10;
        }*/

                /*Scanner in = new Scanner(System.in);
                while (in.hasNextInt()) {
                    int num = in.nextInt();

                    for(int i = 1;i <= num;i ++){
                        for(int j = 1;j <= num;j ++){
                            if(i == j || i + j == num + 1){
                                System.out.print("*");
                            }else{
                                System.out.print(" ");
                            }
                        }
                        System.out.print("\n");

                    }

                }
*/



        /*int input = 0;
        Scanner sc = new Scanner(System.in);
        Random random = new Random();
        int toGuess = random.nextInt(101);
        do{
            System.out.println("输入1开始游戏，输入0退出游戏");
            input = sc.nextInt();
            switch (input){
                case 1:
                    System.out.println("开始游戏");
                    while (true){
                        System.out.println("请输入要猜的数字(1 - 100)");
                        int tmp = sc.nextInt();
                        if(tmp > toGuess){
                            System.out.println("猜大了");
                        }else if(tmp < toGuess){
                            System.out.println("猜小了");
                        }else{
                            System.out.println("猜对了");
                            break;
                        }
                    }
                    break;
                case 0:
                    System.out.println("退出游戏");
                    break;
                default:
                    System.out.println("重新输入");
                    break;
            }
        }while (input != 0);
        sc.close();*/




        /*float sum = 0;
        for(int i = 1;i <= 99;i += 2){
            sum += 1.0/i;
        }
        for(int i = 2;i <= 100;i += 2){
            sum -= 1.0/i;
        }
        System.out.println(sum);*/

        /*
            int count = 0;
            for(int i = 9;i <= 100;i++){

                if(i % 9 == 0 || i / 10 == 9){
                    count++;
                }
            }
            System.out.println(count);
*/


            /* int input = 0;
            Random random = new Random();
            Scanner sc = new Scanner(System.in);
            int toGuess = random.nextInt(101);
            do{
                System.out.println("输入1开始游戏，输入0退出游戏");
                input = sc.nextInt();
                switch (input){
                    case 1:
                        System.out.println("开始游戏");
                        while (true) {
                            System.out.println("请选择数字（0-100）");
                            int num = sc.nextInt();
                            if (num > toGuess) {
                                System.out.println("猜大了，往小了猜");
                            } else if (num < toGuess) {
                                System.out.println("猜小了，往大了猜");
                            } else {
                                System.out.println("猜对了");
                                break;
                            }
                        }
                        break;
                    case 0:
                        System.out.println("退出游戏");
                        break;
                    default:
                        System.out.println("重新输入");
                        break;
                }

            }while(input != 0);
            sc.close();
*/



           /* Scanner sc = new Scanner(System.in);

            int sum = 0,num = 0;
            while(sc.hasNextInt()){
                int tmp = sc.nextInt();
                sum += tmp;
                num++;
            }
            System.out.println("sum = " + sum + "    avg = " + (sum / num));
            sc.close();*/

            /*Scanner sc = new Scanner(System.in);
            System.out.println("请输入你的姓名");
            String name = sc.nextLine();
            System.out.println("请输入你的年龄");
            int age = sc.nextInt();
            System.out.println("请输入你的工资");
            float salary = sc.nextFloat();
            sc.nextLine();
            System.out.println("以后怎么样");
            String LOVE = sc.nextLine();

            System.out.println("你的信息如下");
            System.out.println("姓名：" + name + "\n" + "年龄：" + age + "\n" + "工资：" + salary + "\n" + "以后：" + LOVE);*/


           /* System.out.println("123456");
            System.out.print("1212");
            char c = 'a';
            System.out.printf("%s",c);*/

           /* int add = 0;
            for(int j = 1;j <= 5;j++) {
                int result = 1;
                for (int i = 1; i <= j; i++) {
                    result *= i;
                }
                add += result;
            }
            System.out.println(add);*/

            /*int sum = 0;
            for(int i = 1;i <= 100;i++){
                sum += i;
            }
            System.out.println(sum);*/


       /*     for(int i = 100;i <= 200;i++){
                if(i % 3 == 0){
                    System.out.println("3倍数 = " + i);
                    continue;
                }
            }*/
        /*    int m = 0;
            int add = 0;
            while(++m <= 5) {
                int result = 1;
                int n = 1;
                while (n <= m) {
                    result *= n++;
                }
                add += result;
            }
            System.out.println("add = "+add);
*/


           /* int num = 1;
            int add = 0;
            while(num <= 100){
                add += num++;
            }
            System.out.println(add);*/
            /*int num = 1;
            while(num <= 10){
                System.out.println(num);
                num++;
            }*/

            /*int day = 6;
            switch (day){
                case 1:
                    System.out.println("星期一");
                case 2:
                    System.out.println("星期二");
                case 3:
                    System.out.println("星期三");
                case 4:
                    System.out.println("星期四");
                case 5:
                    System.out.println("星期五");
                    break;
                case 6:
                    System.out.println("星期六");
                case 7:
                    System.out.println("星期天");
                    break;
                default:
                    System.out.println("输入有误");
                    break;
            }*/


/*
            int day = 7;
            switch (day){
                case 1:
                    System.out.println("星期一");
                    break;
                case 2:
                    System.out.println("星期二");
                    break;
                case 3:
                    System.out.println("星期三");
                    break;
                case 4:
                    System.out.println("星期四");
                    break;
                case 5:
                    System.out.println("星期五");
                    break;
                case 6:
                    System.out.println("星期六");
                    break;
                case 7:
                    System.out.println("星期天");
                    break;
                default:
                    System.out.println("输入有误");
                    break;
            }
*/
            /*int year = 2000;
            if(((year % 100 != 0)&&(year % 4 == 0)) || (year % 400 == 0)){
                System.out.println("闰年");
            }else{
                System.out.println("不是闰年");
            }*/


           /* int num = 8;
            if(num > 0) {
                System.out.println("正数");
            }else if(num == 0){
                System.out.println("零");
            }else{
                System.out.println("负数");
            }*/

            /*int num = 0;
            if(num % 2 == 0){
                System.out.println("偶数");
            }else{
                System.out.println("奇数");
            }*/



         /*   System.out.println("hello world!");
            System.out.println(100);
            System.out.println(3.14);
            System.out.println('A');
            System.out.println(true);
            System.out.println(false);


            //整形
            int num1 = 10;
            System.out.println(num1);
            System.out.println(Integer.MIN_VALUE);
            System.out.println(Integer.MAX_VALUE);

            //长整型
            long num2 = 10L;
            System.out.println(num2);
            System.out.println(Long.MIN_VALUE);
            System.out.println(Long.MAX_VALUE);

            //短整形
            short num3 = 10;
            System.out.println(num3);
            System.out.println(Short.MIN_VALUE);
            System.out.println(Short.MAX_VALUE);

            //字节型
            byte num4 = 10;
            System.out.println(num4);
            System.out.println(Byte.MIN_VALUE);
            System.out.println(Byte.MAX_VALUE);

            //双精度浮点型
            double num5 = 10;
            System.out.println(num5);
            System.out.println(Double.MIN_VALUE);
            System.out.println(Double.MAX_VALUE);

            //单精度浮点型
            float num6 = 10f;
            System.out.println(num6);
            System.out.println(Float.MIN_VALUE);
            System.out.println(Float.MAX_VALUE);

            //字符型
            char num7 = 'A';  //大写字母
            char num8 = '你'; //汉字
            System.out.println(num7);
            System.out.println(num8);
            System.out.println(Float.MIN_VALUE);
            System.out.println(Float.MAX_VALUE);

            boolean value = true;
            System.out.println(value + 1);
// 代码编译会出现如下错误
            Test.java:4: 错误: 二元运算符 '+' 的操作数类型错误
            System.out.println(value + 1);
^
            第一个类型: boolean
            第二个类型: int


            System.out.println("aaa");
            System.out.println("bbb");

            分数在 [90, 100] 之间的，为优秀
            分数在 [80, 90) 之前的，为良好
            分数在 [70, 80) 之间的，为中等
            分数在 [60, 70) 之间的，为及格
            分数在 [ 0, 60) 之间的，为不及格
                    错误数据


        System.out.println("请输入成绩");
            Scanner sc = new Scanner(System.in);
            int score = sc.nextInt();
            if(score >= 90 && score <= 100){
                System.out.println("优秀");
            } else if(score >= 80 && score < 90) {
                System.out.println("良好");
            }else if(score >= 70 && score < 80){
                System.out.println("中等");
            }else if(score >= 60 && score < 70){
                System.out.println("及格");
            }else if(score >= 0 && score < 60){
                System.out.println("不及格");
            }else{
                System.out.println("错误数据");
            }
*/
        }
}


